package com.weixinli.beans;

import java.io.Serializable;

public class Article implements Serializable{
	private int aid;//杂志编号
	private String aname;//杂志题目
	private String aaddr;//杂志图片地址
	private String acontent;//杂志内容
	private String aauthor;//杂志作者
	private String atime;//杂志时间
	private String atype;//杂志类型
	private static final long serialVersionUID = 1L;
	
	@Override
	public String toString() {
		return "Article [aid=" + aid + ", aname=" + aname + ", aaddr=" + aaddr
				+ ", acontent=" + acontent + ", aauthor=" + aauthor
				+ ", atime=" + atime + ", atype=" + atype + "]";
	}

	public int getAid() {
		return aid;
	}
	
	public int getAids() {
		return aid;
	}

	public void setAid(int aid) {
		this.aid = aid;
	}

	public String getAname() {
		return aname;
	}

	public void setAname(String aname) {
		this.aname = aname;
	}

	public String getAaddr() {
		return aaddr;
	}

	public void setAaddr(String aaddr) {
		this.aaddr = aaddr;
	}

	public String getAcontent() {
		return acontent;
	}

	public void setAcontent(String acontent) {
		this.acontent = acontent;
	}

	public String getAauthor() {
		return aauthor;
	}

	public void setAauthor(String aauthor) {
		this.aauthor = aauthor;
	}

	public String getAtime() {
		if(atime!=null && !"".equals(atime) && atime.indexOf(" ")>0){
			return atime.substring(0,atime.indexOf(" "));
		}else{
			return atime;
		}
	}

	public void setAtime(String atime) {
		this.atime = atime;
	}

	public String getAtype() {
		return atype;
	}
	
	public void setAtype(String atype) {
		this.atype = atype;
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + ((aaddr == null) ? 0 : aaddr.hashCode());
		result = prime * result + ((aauthor == null) ? 0 : aauthor.hashCode());
		result = prime * result
				+ ((acontent == null) ? 0 : acontent.hashCode());
		result = prime * result + aid;
		result = prime * result + ((aname == null) ? 0 : aname.hashCode());
		result = prime * result + ((atime == null) ? 0 : atime.hashCode());
		result = prime * result + ((atype == null) ? 0 : atype.hashCode());
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		Article other = (Article) obj;
		if (aaddr == null) {
			if (other.aaddr != null)
				return false;
		} else if (!aaddr.equals(other.aaddr))
			return false;
		if (aauthor == null) {
			if (other.aauthor != null)
				return false;
		} else if (!aauthor.equals(other.aauthor))
			return false;
		if (acontent == null) {
			if (other.acontent != null)
				return false;
		} else if (!acontent.equals(other.acontent))
			return false;
		if (aid != other.aid)
			return false;
		if (aname == null) {
			if (other.aname != null)
				return false;
		} else if (!aname.equals(other.aname))
			return false;
		if (atime == null) {
			if (other.atime != null)
				return false;
		} else if (!atime.equals(other.atime))
			return false;
		if (atype == null) {
			if (other.atype != null)
				return false;
		} else if (!atype.equals(other.atype))
			return false;
		return true;
	}

	public Article(int aid, String aname, String aaddr, String acontent,
			String aauthor, String atime, String atype) {
		super();
		this.aid = aid;
		this.aname = aname;
		this.aaddr = aaddr;
		this.acontent = acontent;
		this.aauthor = aauthor;
		this.atime = atime;
		this.atype = atype;
	}

	public Article() {
		super();
	}
}
